package com.colbby.datahouse.transform;

import com.colbby.datahouse.utils.CastUtils;
import com.colbby.datahouse.utils.TypeDescriptor;
import com.colbby.datahouse.utils.TypeUtils;

public class DoubleTransformer implements DataTypeTransform<Double> {

	public static final DoubleTransformer INSTANCE = new DoubleTransformer();
	
	@Override
	public Double transform(TypeDescriptor returnType, Object value) {
		return CastUtils.castToDouble(CastUtils.getValue(value));
	}

	@Override
	public boolean shouldDo(TypeDescriptor returnType, Object value) {
		return TypeUtils.isSuperClass(Double.class, returnType.getTypeClass());
	}
}
